import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ball_lion/service/config_service.dart';
import 'package:ball_lion/resources/colours.dart';
import 'package:ball_lion/resources/styles.dart';
import 'package:ball_lion/utils/utils.dart';
import 'package:ball_lion/utils/widget_utils.dart';
import 'package:ball_lion/widgets/base/wqs_widget.dart';

import 'package:ball_lion/widgets/base/wqs_text.dart';

class OddsCompanyPage extends StatefulWidget {
  const OddsCompanyPage({super.key});

  @override
  State<OddsCompanyPage> createState() => _OddsCompanyPageState();
}

class _OddsCompanyPageState extends State<OddsCompanyPage> {
  ConfigService configService = Get.find<ConfigService>();
  //0足球  1篮球
  int type = Get.arguments;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Styles.appBar(title: QsText(type == 0 ? '足球指数公司' : '篮球指数公司')),
      backgroundColor: Colours.scaffoldBg,
      body: ListView(children: [
        SizedBox(height: 10),
        Styles.card(
            margin: EdgeInsets.symmetric(horizontal: 8),
            child: Column(
                children: configService.oddsCompany
                    .map<Widget>((e) {
                      if (type == 0) {
                        return QsWidget.selectCell(e.name ?? '',
                            configService.zqConfig.zqList8 == e.id, onTap: () {
                          configService.zqConfig.zqList8 = e.id!;
                          update();
                          configService.update(ConfigType.zqList8,
                              configService.zqConfig.zqList8);
                        });
                      } else {
                        return QsWidget.selectCell(e.name ?? '',
                            configService.lqConfig.lqList8 == e.id, onTap: () {
                          configService.lqConfig.lqList8 = e.id!;
                          update();
                          configService.update(ConfigType.lqList8,
                              configService.lqConfig.lqList8);
                        });
                      }
                    })
                    .toList()
                    .insertEvery(QsWidget.seperateLine())))
      ]),
    );
  }
}
